package com.mydemo.springlearning.functions.memoryshare.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.mydemo.springlearning.functions.memoryshare.entity.BigUser;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.mapping.ResultSetType;
import org.apache.ibatis.session.ResultHandler;

import java.util.List;

@Mapper
public interface BigUserMapper {

    /**
     * 获取所有用户
     *
     * @return
     */
    List<BigUser> getAllBigUser();


    @Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 5000)
    Cursor<BigUser> getBigUserByStream();

    /**
     * <U>流式查询</U>
     * 查询快，内存占用小，组装对象慢
     *
     * @param limit 限制查询数目
     * @return 结果List
     */
    @Select(" SELECT\n" +
            "            \"id\",\"birthday\",\"ding_union_id\",\"ds_order\",\"email\",\"id_card\",\n" +
            "            \"job_grade_text\",\"job_grade_value\",\"name\",\"nation_text\",\n" +
            "            \"openid\",\"phone\",\"py\",\"pinyin\",\"sex_text\",\"sex_value\",\"state_text\",\"state_value\"\n" +
            " FROM\n" +
            "   dsfa_oua_user\n" +
            " WHERE ds_deleted = '0'\n" +
            " order by ds_order limit #{limit}")
    Cursor<BigUser> getBigUserLimit(@Param("limit") int limit);
}
